using UnityEngine;
using System.Collections;

/// \class  gkAbyssalGiantPlantMeshBlenderTarget
/// \brief  Set the target of an plant mesh blender
[AddComponentMenu("GK/AbyssalGiant/Plant/gkAbyssalGiantPlantMeshBlenderTarget")]
public class gkAbyssalGiantPlantMeshBlenderTarget : MonoBehaviour 
{
	/// The mesh blender
	public gkAbyssalGiantPlantMeshBlender MeshBlender;
	
	/// The target
	public Transform Target;
	
	/// The initial local position
	private Vector3 m_f3InitialLocalPosition;
	
	/// \brief  Called just after the game begin to play
    void Start()
    {		
		// Save the initial local position
		m_f3InitialLocalPosition = transform.InverseTransformPoint(Target.position);
	}
	
	/// \brief  Update is called once per frame
	void Update () 
	{
		// Set the head look controller target position
		// based on the target position
		if(Target != null)
		{
			MeshBlender.LocalTargetOffset = transform.InverseTransformPoint(Target.position) - m_f3InitialLocalPosition;
		}
	}
}
